import gameCtr from "../ctrs/gameCtr";
import { SoundResManager } from "../ctrs/soundCtr";
import BaseEle, { campType, soliderType } from "./baseEle";

/**
 * @Author: 陈瑞鹏
 * @Date:   2022-11-28 18:03:44
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2022-12-12 09:19:52
 */
const { ccclass, property } = cc._decorator;

@ccclass

export default class frozenEle extends cc.Component {
  @property({ type: cc.Animation, tooltip: "" })
  ani: cc.Animation = null;

  @property({ type: cc.Sprite, tooltip: "" })
  sp: cc.Sprite = null;

  public aoeNum: number = 5; //aoe能造成的最大伤害数量

  private num: number = 0;

  campType: campType;

  private life: number = 180;//3秒

  protected onEnable(): void {

  }

  /**
   * 设置aoe数量
   */
  public setInfo(info) {
    this.campType = info.campType || 1;
    this.life = info.life || 180;
    // this.ani.once("finished", this.recover, this);
  }


  /**
   * 回收
   */
  recover() {
    this.num = 0;
    if (gameCtr.ins.poolObj['frozen']) {
      gameCtr.ins.poolObj['frozen'].put(this.node);
    } else {
      this.node.removeFromParent();
    }
  }

  protected update(dt: number): void {
    if (this.life < 0) {
      this.recover();
    } else {
      this.life--;
    }
  }
}